<?php
namespace app\api\model;
class AssessmentHand
{
    public static function GetAssessment($type){
        $first_sentence = sysconfig('assessment','diyiju');
        $last = sysconfig('assessment','zuihou');
        if($type==1){
            $data = OptionType::where('status',1)
                ->where('nursing_lang_id',8)
                ->field('id,name,problem')
                ->order('sort desc')
                ->select()->toArray();
            foreach ($data as $key=>$value){
                $option = DiseaseUser::where('status',1)
                    ->where('option_type_id',$value['id'])
                    ->column('name');
                $value['option'] = $option;
                $data[$key] = $value;
            }
            $res['first_sentence'] = $first_sentence;
            $res['last'] = $last;
            $res['dialogue'] = $data;
        }else{
            $data = NursingType::where('status',1)
                ->order('sort desc')
                ->field('id,name,problem')
                ->select()->toArray();
//            echo '<pre>';
//            print_r($data);
//            exit;
           foreach ($data as $key=>$value){
               $option = Nursing::where('status',1)
                   ->where('type',$value['id'])
                   ->order('sort desc')
                   ->column('name');
               $value['child'] = $option;
               $data[$key] = $value;
           }
            $res['first_sentence'] = $first_sentence;
            $res['last'] = $last;
            $res['dialogue'] = $data;
        }
        return $res;
    }
}